#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#define int long long
using namespace std;
string s,op;
int n,x,sum;
signed main(){
	cin>>s>>n;
	int f=1;
	int len=s.size();
	while(n--)
	{
		cin>>op;
		if(op=="<"){
			cin>>x;
			if(f==1) sum-=x;
			else sum+=x;
		} 
		if(op==">"){
			cin>>x;
			if(f==1) sum+=x;
			else sum-=x;
		}
		if(op=="rev"){
			f=1-f;
		}
	}
	sum%=len;
	if(sum<0) sum=abs(sum),rotate(s.begin(),s.begin()+sum,s.end());
	else rotate(s.rbegin(),s.rbegin()+sum,s.rend());
	if(f==0) reverse(s.begin(),s.end());
	cout<<s;
	return 0;
}
